package com.wx.elasticsearch.dao;

import com.wx.elasticsearch.pojo.EsProduct;
import org.springframework.stereotype.Repository;

import java.math.BigDecimal;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author wangxun
 */
@Repository
public class EsProductDao {

    public static final Map<Long, EsProduct> repository = new HashMap<>();

    static {
        repository.put(1L, new EsProduct(1L, "/img/01-png", new BigDecimal("6999.99"), 10, 1, 1, 1L, "iPhone13手机", "手机", "手机 大哥大 iPhone 智能 苹果", "1001a", "iPhone", "手机"));
        repository.put(2L, new EsProduct(2L, "/img/02-png", new BigDecimal("5899.98"), 20, 2, 0, 2L, "ThinkPad电脑", "电脑", "电脑 PAD Think 15.6 联想", "1002b", "联想", "电脑"));
        repository.put(3L, new EsProduct(3L, "/img/03-png", new BigDecimal("23.99"), 30, 3, 1, 3L, "双层水杯", "水杯", "水杯 双层 潮流 保温 优质", "1003c", "南极人", "水杯"));
        repository.put(4L, new EsProduct(4L, "/img/04-png", new BigDecimal("1299.99"), 40, 4, 0, 4L, "冰兰床垫", "床垫", "床垫 冰兰 无甲醛 棕榈垫", "1004d", "冰兰", "床垫"));
    }

    public EsProduct getById(Long id) {
        return repository.get(id);
    }

    public Collection<EsProduct> getAll() {
        return repository.values();
    }
}
